package com.neiquan.neiquandemo.activity;

import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.view.WindowManager;

import com.neiquan.neiquandemo.R;

import net.neiquan.applibrary.base.BaseActivity;

import java.io.File;

/**
 * Created by cxh on 2016/9/9.
 */
public class SplashActiviy extends BaseActivity {

    @Override
    public int getRootViewId() {
        return R.layout.activity_splash;
    }

    @Override
    public void setViews() {
        getWindow ().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);  //全屏
        new Handler().postDelayed(new Runnable() {

            @Override
            public void run() {
                startActivity(new Intent(SplashActiviy.this,MainActivity.class));
                finish();
            }
        }, 1200);
    }

    @Override
    public void initData() {
        //启动页下载并展示
//        String path = DonwloadSaveImg.cityChangeUrl;
//        String name = filenames[filenames.length - 1];
//        final File imgFile = new File(path + name);
////                                            if (!imgFile.exists()){//判断文件是否存在 不存在则下载
////                                                DonwloadSaveImg.donwloadCityImg(imgs[n], name);
////                                            }
//        if (!imgFile.exists()) {//判断文件是否存在 不存在则下载
////                                            Logger.e("imgName3",imgUrls.get(n));
////                                            DonwloadSaveImg.donwloadBigImg(imgUrls.get(n), imgName[imgName.length-1]);
//            Intent intent = new Intent(SplashActivity.this, DownloadImgService.class);
//            intent.putExtra("downloadUrl", imgs[n]);
//            intent.putExtra("name", name);
//            intent.putExtra("filePath", Environment.getExternalStorageDirectory().getAbsolutePath() + "/.citychangeimage/");
//            startService(intent);
//        }


//        if (!StringUtils.isEmpty(bean.getTitleFilepath().get(j)) && bean.getTitleFilepath().get(j).contains("http")) {
//            String[] imgName = bean.getTitleFilepath().get(j).split("/");
//            String path = Environment.getExternalStorageDirectory().getAbsolutePath() + DonwloadSaveImg.startappUrl;
//            File imgFile = new File(path + imgName[imgName.length - 1]);
//            Logger.e("imgName1", path + imgName[imgName.length - 1]);
//            if (imgFile.exists()) {
//                Uri uri;
//                if (Build.VERSION.SDK_INT >= 24) {
//                    uri = FileProvider.getUriForFile(SplashActivity.this, App.fileProvider, imgFile);
//                } else {
//                    uri = Uri.fromFile(imgFile);
//                }
//                Logger.e("imgName2", uri.toString());
//                listUrls.add(uri.toString());
//                linkUrls.add(bean.getListContent().get(j).getStartAdLink());
//            } else {
//                listUrls.add(bean.getTitleFilepath().get(j));
//                linkUrls.add(bean.getListContent().get(j).getStartAdLink());
//            }
//        }


        //底部导航下载并展示
        //        if (!StringUtils.isEmpty(tab.getImgUrl())) {
//            filename = tab.getImgUrl().substring(tab.getImgUrl().lastIndexOf("/") + 1);
//            DonwloadSaveImg.donwloadImg(tab.getImgUrl(), filename);
//        }
//        for (int j = 0; j < themesize; j++) {
//            tabBean.subjectsBean bean = tab.getSubjects().get(j);
//            if (!StringUtils.isEmpty(bean.getSubjectImgUrl())) {
//                url = bean.getSubjectImgUrl();
//                filename = bean.getSubjectImgUrl().substring(bean.getSubjectImgUrl().lastIndexOf("/") + 1);
//            }
//            DonwloadSaveImg.donwloadImg(url, filename);
//        }


//        File myCaptureFile = new File(tab.getLocalFilePath());
//        File themeNameFile = new File(subPath);
//        if (myCaptureFile.exists() && themeNameFile.exists()) {
//            bottom_menu.addTab(new BottomLayout.Tab(tab.getName(), 0, tab.getLocalFilePath(), subPath, R.color.bottomBarHint, currThemeColor, tab.getCsstype(), tab.getHideText()));
//        } else {
//            bottom_menu.addTab(new BottomLayout.Tab(tab.getName(), 1, tab.getImgUrl(),
//                    url,
//                    R.color.bottomBarHint,
//                    currThemeColor, tab.getCsstype(), tab.getHideText()));
//        }
    }
}
